package com.cooldatasoft.domain.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@SuppressWarnings("serial")
@Entity
@Table(name = "Event", catalog = "ws1259000db")
public class Event implements Serializable {

	private long idEvent;
	private Date start;
	private Date end;
	private String caption;
	private String description;
	private String styleName;
	private boolean all_day;
	private User idUser;
	
	public Event() {
		// TODO Auto-generated constructor stub
	}
	
	public Event(long idEvent, Date start, Date end, String caption, String description) {
		this.idEvent = idEvent;
		this.start = start;
		this.end = end;
		this.caption = caption;
		this.description = description;
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id_event", unique = true, nullable = false)
	public long getIdEvent() {
		return idEvent;
	}
	
	public void setIdEvent(long idEvent) {
		this.idEvent = idEvent;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "start", nullable = false)
	public Date getStart() {
		return start;
	}
	
	public void setStart(Date start) {
		this.start = start;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "end", nullable = false)
	public Date getEnd() {
		return end;
	}
	
	public void setEnd(Date end) {
		this.end = end;
	}
	
	@Column(name = "caption", nullable = false, length = 50)
	public String getCaption() {
		return caption;
	}
	
	public void setCaption(String caption) {
		this.caption = caption;
	}
	
	@Column(name = "description", length = 500)
	public String getDescription() {
		return description;
	}
	
	public void setDescription(String description) {
		this.description = description;
	}
	
	@Column(name = "style_name")
	public String getStyleName() {
		return styleName;
	}
	
	public void setStyleName(String styleName) {
		this.styleName = styleName;
	}
	
	@Column(name = "all_day")
	public boolean isAll_day() {
		return all_day;
	}
	
	public void setAll_day(boolean all_day) {
		this.all_day = all_day;
	}
	
	public void setIdUser(User user) {
		this.idUser = user;
	}
	
	@ManyToOne
	@JoinColumn(name = "id_user", nullable = true)
	public User getIdUser() {
		return idUser;
	}
	
	@Override
	public String toString() {
		return "EVENT: \nid: " + idEvent + " \nstart: " + start + " \nend: " + end + " \ncaption: " + caption + " \ndescription: " + description;
	}
}
